package com.fire.control.system.module.duty.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.fire.control.system.dto.DutyRequestDTO;
import com.fire.control.system.entity.Duty;
import com.fire.control.system.entity.DutyLeave;
import com.fire.control.system.entity.NoticeDetail;
import com.fire.control.system.entity.User;
import com.fire.control.system.support.protocol.duty.LeaveDutyRequestProtocol;

public interface DutyMapper {
	
	public int updateTodayDutyNoAttendance();
	
	public int sign(Duty duty);
	
	//插入请假记录
	public int saveDutyLeave(DutyLeave dutyLeave);
	
	//查询通知列表
	@Select("select * from t_notice_detail" )
	public List<NoticeDetail> searchNoticeDetail();
	
	/**
	 * @author liuxincheng
	 * @Title: getDutySheetByCondition
	 * @Description: TODO(根据条件获得值班列表)
	 * @param @param duty
	 * @param @return    设定文件
	 * @return List<Duty>    返回类型
	 * @throws null
	 */
	public List<Duty> getDutySheetByCondition(LeaveDutyRequestProtocol leaveDutyRequestProtocol);
	
	/**
	 * @author liuxincheng
	 * @Title: getDutySheetByUserId
	 * @Description: TODO(查询该用户下的值班列表)
	 * @param @param userId
	 * @param @return    设定文件
	 * @return List<Duty>    返回类型
	 * @throws null
	 */
	@Select("select d.* from t_duty d where d.user_id = #{userId}")
	public List<Duty> getDutySheetByUserId(@Param("userId")String userId);
	
	/**
	 * @author liuxincheng
	 * @Title: getUserByUserId
	 * @Description: TODO(根据用户Id查询用户信息)
	 * @param @param userId
	 * @param @return    设定文件
	 * @return User    返回类型
	 * @throws null
	 */
	@Select("select u.* from t_users u where u.id=#{userId}")
	public User getUserByUserId(@Param("userId")String userId);
	
	/**
	 * @author liuxincheng
	 * @Title: getUserIdByName
	 * @Description: TODO(根据用户名查找用户信息)
	 * @param @param userName
	 * @param @return    设定文件
	 * @return String    返回类型
	 * @throws null
	 */
	@Select("select u.* from t_users u where u.name=#{userName}")
	public User getUserByName(@Param("userName")String userName);
	
	/**
	 * @author liuxincheng
	 * @Title: getCompanyIdByUserId
	 * @Description: TODO(根据userId获取companyId)
	 * @param @param userId
	 * @param @return    设定文件
	 * @return String    返回类型
	 * @throws null
	 */
	@Select("select u.company_id from t_users u where u.id=#{userId}")
	public String getCompanyIdByUserId(@Param("userId")String userId);
	
	/**
	 * @author liuxincheng
	 * @Title: getDutyListByCodition
	 * @Description: TODO(根据条件查询该用户下的签到表)
	 * @param @param userId
	 * @param @param dutyStatus
	 * @param @return    设定文件
	 * @return List<Duty>    返回类型
	 * @throws null
	 */
	@Select("select d.* from t_duty d where d.user_id=#{userId} and d.duty_status=#{dutyStatus} and year(d.sign_time) =#{year} and month(d.sign_time)=#{month}")
	public List<Duty> getDutyListByCodition(@Param("userId")String userId,@Param("dutyStatus")String dutyStatus,@Param("year") int year,@Param("month")int month);
    
	/**
	 * @author liuxincheng
	 * @Title: getDutyList
	 * @Description: TODO(获取我的值班表)
	 * @param @param userId
	 * @param @param year
	 * @param @param month
	 * @param @return    设定文件
	 * @return List<Duty>    返回类型
	 * @throws null
	 */
	@Select("select d.* from t_duty d where d.user_id=#{userId} and year(d.duty_date) =#{year} and month(d.duty_date)=#{month}")
	public List<Duty> getDutyList(@Param("userId")String userId,@Param("year") int year,@Param("month")int month);

	public List<Map<String, Object>> findDutyList(LeaveDutyRequestProtocol leaveDutyRequestProtocol);
}
